(deftemplate animal
    (slot nume)
    (slot hrana)
    (slot modViata) /* diurn/nocturn */
    (slot mediuViata) /* terestru, aerian, subteran, acvatic, semi_acvativ */
    (slot modalitateReproducere) /* oua, pui_vii */
    (slot zona) /* mediteraniana, continentala, subtropicala, polara */
    (slot pradator)
    (multislot prada)    
)

(deffacts baza_de_animale
	(animal
    	(nume broasca)    
        (hrana carnivor)
        (modViata diurn)
        (mediuViata semi_acvatic)
        (modalitateReproducere oua)
        (zona mediteraniana)
        (pradator sarpe)
        (prada musca)
    )    
   
	(animal
    	(nume musca)    
        (hrana omnivor)
        (modViata diurn)
        (mediuViata aerian)
        (modalitateReproducere oua)
        (zona mediteraniana)
        (pradator broasca)
        (prada nil)
    )     

    (animal
    	(nume sarpe)    
        (hrana carnivor)
        (modViata diurn)
        (mediuViata semi_acvatic)
        (modalitateReproducere oua)
        (zona tropicala)
        (pradator arici)
        (prada broasca)
    )
    
    (animal
    	(nume cal)    
        (hrana ierbivor)
        (modViata diurn)
        (mediuViata terestru)
        (modalitateReproducere pui_vii)
        (zona mediteraniana)
        (pradator lup)
        (prada nil)
    )
    
    (animal
    	(nume lup)    
        (hrana omnivor)
        (modViata diurn)
        (mediuViata terestru)
        (modalitateReproducere pui_vii)
        (zona continentala)
        (pradator om)
        (prada cal vaca oaie)
    )
    
    (animal
    	(nume urs)    
        (hrana omnivor)
        (modViata diurn)
        (mediuViata terestru)
        (modalitateReproducere pui_vii)
        (zona polara)
        (pradator om)
        (prada foca)
    )
    
    (animal
    	(nume foca)    
        (hrana carnivor)
        (modViata diurn)
        (mediuViata semi_acvatic)
        (modalitateReproducere pui_vii)
        (zona polara)
        (pradator urs)
        (prada pesti)
    )
    
)

(defrule animale_semiacvatice
    (declare (salience -1))
    (animal
    	(nume ?n)
        (mediuViata semi_acvatic & ?mv)    
    )
    
    =>
    
    (printout t "Animalul "?n" este "?mv"." crlf)
)

(defrule animale_vegetariene_zona_mediteraniana
    (declare (salience -2))
    (animal
        (nume ?n)
        (hrana ierbivor & ?h)
        (zona mediteraniana & ?z)
    )
    
    =>
    
    (printout t "Animalul "?n" este "?h" si traieste in zona "?z"." crlf)
)

(defrule prada_pradator
    (declare (salience -5))
    (animal
    	(nume ?n1)
        (pradator ?p1)
    )
    
     (animal
    	(nume ?n2 & :(eq ?n2 ?p1))
    ) 
    
    =>
    
    (printout t ?n1" este vanata de "?n2 crlf)
)

(defrule antipattern
    (declare (salience -6))
   
    (animal
    	(nume ?n)
        (zona ?z & ~mediteraniana & ~continentala & ~subtropicala & ~tropicala)
    )
    
    =>
    
    (printout t ?n" traieste in zona polara." crlf)
)

(reset)
(run)